package 工厂方法模式.改进;

import 简单的工厂模式.工厂模式demo.计算器.Operation;

/**
 * @author zyl
 * @Description
 * @since 2024/1/3 13:17
 */

public class OperationFactory {
    Operation operation = null;
    IFactory iFactory = null;
    public Operation creatOperation(String operator){
        switch (operator){
            case "+":
            case "-":
            case "*":
            case "/":
                iFactory = new FactoryBasic();
                break;
            case "pow":
            case "log":
                iFactory = new FactoryAdvanced();
                break;
        }
        operation = iFactory.creatOperation(operator);
        return this.operation;
    }
}
